
<%@ page import="java.util.List" %>
<%@ page import="coop.bancocredicoop.proyectos.gd.controller.buscarCliente.
		BuscarClienteController" %>
<%@ page import="coop.bancocredicoop.proyectos.gd.crecerxxi.
		CrecerXXICustomer" %>

<%
	new BuscarClienteController().run(request);
%>

<script>
	function seleccionarCustomer(internalId, name, cuit) {
		$('#customerId').val(internalId)
        var customerDescription = internalId + ' (' + name + ', CUIT: ' + cuit + ')'
		$('#customerDescription').val(customerDescription)
		$('#customer').html(customerDescription)
		$('#buscarClienteModal').modal('hide')
		return false
	}
</script>

<% if (request.getAttribute("error") != null) { %>
	<div class="alert alert-danger">
	<ul class="errors">
		<li><%=request.getAttribute("error") %></li>
	</ul>
	</div>
<% } else { %>
			<table class="table table-striped">
				<thead>
					<tr>
						<th>Id</th>
						<th>Nombre</th>
						<th>CUIT</th>
					</tr>
				</thead>
				<tbody>
				<% for (CrecerXXICustomer customer : (List<CrecerXXICustomer>) request.getAttribute("listCustomer")) { %>
					<tr>
						<td>
							<a onclick="return seleccionarCustomer('<%=customer.getInternalId() %>', '<%=customer.getName() %>', '<%=customer.getCuit() %>')" href="#">
								<%=customer.getInternalId() %>
							</a>
						</td>
						<td><%=customer.getName() %></td>
						<td><%=customer.getCuit() %></td>
					</tr>
				<% } %>
				</tbody>
			</table>
<% } %>
